<template>
	<view class="mainbgc mainpadding">
		<view class="">
			<!-- 订单状态 -->
			<view class="bigtext" v-if="dataAll.state==0">等待商家处理</view>
			<view class="bigtext" v-if="dataAll.state==2">商家拒绝</view>
			<view class="bigtext" v-if="dataAll.state==1">等待买家寄回</view>
			<view class="bigtext" v-if="dataAll.state==6">等待商家确认收货</view>
			<view class="bigtext" v-if="dataAll.state==4">退货完成</view>
		</view>
		<!--订单时间状态  -->
		<view class="margin_top1">
			<view class="strongtext " v-if="dataAll.state==0">您已发起退款申请等待商家审核！</view>
			<view class="strongtext " v-if="dataAll.state==1">卖家已同意您的申请请将商品寄回！</view>
			<view class="strongtext " v-if="dataAll.state==6">商家确认收货会将您的金额退回！</view>
			<view class="strongtext " v-if="dataAll.state==4">您的金额已原路退回，请注意查收！</view>
			<view class="strongtext " v-if="dataAll.state==2">拒绝理由：{{dataAll.refuse_content}}</view>
		</view>
		<!-- 寄回地址 -->
		<view class="mainpadding ffffff radius margin_top" v-if="dataAll.state==1">
			<view class="titletext">寄回地址</view>
			<view class="flexleft margin_top2">
				<view class="titletext margin_right3">{{dataAll.refund_name}}</view>
				<view class="titletext">{{dataAll.refund_mobile}}</view>
			</view>
			<view class="huisetext margin_top2">{{dataAll.refund_address}}</view>
		</view>
		<!-- 退款金额 -->
		<view class="mainpadding ffffff radius margin_top flexbetween">
			<view class="titletext">退款金额</view>
			<view class="qianshu">￥{{dataAll.price}}</view>
		</view>
		<!-- 快递单号 -->
		<view class="mainpadding ffffff radius margin_top" v-if="dataAll.state==6">
			<view class="flexbetween">
				<view class="titletext">快递公司</view>
				<view class="notitletext">{{dataAll.express_name}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="titletext">快递单号</view>
				<view class="notitletext">{{dataAll.express_no}}</view>
			</view>
		</view>
		<!-- 商品 -->
		<view class="ffffff mainpadding radius margin_top">
			<!-- 退货商品 -->
			<view class="titletext">退货商品</view>
			<view class=" xiahuax margin_top">
				<view class="flexbetween">
					<view class="shilitu">
						<image :src="dataAll.goods.image_text" mode=""></image>
					</view>
					<view class="" style="width: 74%;">
						<view class="titletext yhxiank">{{dataAll.goods.title}}</view>
						<view class="ershib margin_top1 yhxiank">{{dataAll.goods.difference}}</view>
						<view class="flexbetween margin_top1">
							<view class="qianshu">¥{{dataAll.goods.price}}</view>
							<view class="shuliang">x{{dataAll.goods.number}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 商品详情 -->
		<view class="paddingbom">
			<view class="ffffff mainpadding radius margin_top">
				<view class="flexbetween margin_top">
					<view class="ershil">退货原因</view>
					<view class="huisetext">{{dataAll.reason}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil">退款金额</view>
					<view class="huisetext" style="color: #FD463E;">{{dataAll.price}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil">退货编号</view>
					<view class="huisetext">{{dataAll.refund_no}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="ershil">申请时间</view>
					<view class="huisetext">{{dataAll.createtime_text}}</view>
				</view>
			</view>
		</view>

		<!-- 固定底部 -->
		<view class="gudingdb ffffff">
			<view class="flexright">
				<view class="huisebtn" v-if="dataAll.state==0" @click="cancelorder">取消申请</view>
				<view class="huangsebtn marginleft" v-if="dataAll.state==1" @click="jumpdetail()">填写单号</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll: {}
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.init()
		},

		methods: {
			init() {
				httpRequest.request('/api/order/getRefundInfo', 'POST', {
					id: this.listid,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.dataAll = res.data
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			cancelorder() {
				httpRequest.modal('提示', '请再次确认', true, (res) => {
					if (res) {
						httpRequest.request('/api/order/closeRefund', 'POST', {
							id: this.listid,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								setTimeout(()=>{
									uni.navigateBack(1)
								},1000)
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
				
			},
			jumpdetail() {
				let data = {
					kuaidi: this.dataAll.kuaidi,
					id: this.listid
				}
				uni.navigateTo({
					url: '/pages/mypage/tianxiedh?msg=' + encodeURIComponent(JSON.stringify(data))
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.marginleft {
		margin-left: 30rpx;
	}

	.mainbgc {
		box-sizing: border-box;
	}

	.huangsebtn {
		border: 2rpx solid rgba(34, 141, 255, 1);
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(34, 141, 255, 1);
	}

	.huisebtn {
		border: 2rpx solid #666666;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.shuliang {
		font-size: 26rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #999999;
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.shilitu {
		width: 134rpx;
		height: 128rpx;
		border-radius: 14rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.qianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: RGBA(253, 70, 62, 1);
	}

	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.yhxiank {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.paddingbom {
		padding-bottom: 200rpx;
	}
</style>